package com.lianyu.wangyiyun.model;

import android.content.ContentValues;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.lianyu.wangyiyun.utils.HistoryHelper;

import java.io.Serializable;
import java.util.Date;

/**
 * @author Chen Yuguang
 */
public class Mp3Info implements Serializable {

    private long id = 0;
    private String title = "";
    private String artist = "";
    private String url = "";
    private String album = "";
    private boolean isFavorite = false;

    @Override
    public boolean equals(@Nullable Object obj) {
        if (obj instanceof Mp3Info) {
            return this.id == ((Mp3Info) obj).id;
        } else {
            return false;
        }
    }

    public boolean equals(@NonNull Mp3Info mp3Info) {
        return this.title.equals(mp3Info.title) && this.artist.equals(mp3Info.artist)
                && this.url.equals(mp3Info.url) && this.album.equals(mp3Info.album) && this.isFavorite == mp3Info.isFavorite;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getId() {
        return this.id;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return this.title;
    }

    public void setArtist(String artist) {
        this.artist = artist;
    }

    public String getArtist() {
        return this.artist;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getUrl() {
        return this.url;
    }

    public String getAlbum() {
        return album;
    }

    public void setAlbum(String album) {
        this.album = album;
    }

    public void setFavorite(boolean favorite) {
        this.isFavorite = favorite;
    }

    public boolean isFavorite() {
        return isFavorite;
    }

    public ContentValues toContentValues() {
        ContentValues contentValues = new ContentValues(5);
        contentValues.put(HistoryHelper.COLUMN_NAME_ID, id);
        contentValues.put(HistoryHelper.COLUMN_NAME_TITLE, title);
        contentValues.put(HistoryHelper.COLUMN_NAME_ARTIST, artist);
        contentValues.put(HistoryHelper.COLUMN_NAME_URL, url);
        contentValues.put(HistoryHelper.COLUMN_NAME_ALBUM, album);
        contentValues.put(HistoryHelper.COLUMN_NAME_TIME, System.currentTimeMillis());
        return contentValues;
    }

}